<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="/WEB-INF/tag/pagetag.tld" prefix="p"%>
<%@ taglib uri="/WEB-INF/tag/pageform.tld" prefix="pf"%>
<!doctype html>
<html lang="zh-CN">
<head>
<title>用户授权</title>
    
    <!-- 静态引入 -->
    <c:import url="/WEB-INF/views/config/include.jsp" charEncoding="UTF-8"/>
	<script src="/public/other/js/jquery.cookie.js"></script>
	
</head>

<body>


	<script type="text/javascript">
		var openId = $.cookie('wx_openId');//取出值
		//判断用户是否已经授权
		if (openId == null || openId == "") {
			//第一步：用户同意授权，获取code
			//自动授权
			location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${redirect}&response_type=code&scope=snsapi_base&state=${state}#wechat_redirect";
			//手动授权
			//location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${redirect}&response_type=code&scope=snsapi_userinfo&state=${state}#wechat_redirect";
		}
		//已经授权的场合自动登录
		else {			
			//自动登录
			location.href = "${login_href}?openId=" + openId;
		}
	</script>
</body>
</html>
